#ifndef	__BFX_XMLERROR_H__
#define	__BFX_XMLERROR_H__

namespace BFX
{

//////////////////////////////////////////////////////////////////////////////

enum XMLError
{
	XML_Success = 0,
	XML_InvalidVersionNumber,
	XML_MissingRoot,
	XML_MultipleRoots,
	XML_InvalidRootData,
	XML_UnclosedQuote,
	XML_UnexpectedEndTag,
	XML_BadDTDLocation,	// unnecessary?
	XML_DtdAfterRootElement,
	XML_InvalidPIName,
	XML_UnexpectedEOF,
	XML_InvalidXmlDecl,
	XML_InvalidTextDecl,
	XML_XmlDeclNotFirst,
	XML_UnexpectedToken,
	XML_BadNameChar,
	XML_BadStartNameChar,
	XML_ExpectingWhiteSpace,
	XML_UnexpectedEOFInElementContent,
	XML_InvalidCharacter,
	XML_BadAttributeChar,
	XML_InvalidCommentChars,
	XML_CDATAEndInText,
	XML_BadHexEntity,
	XML_BadDecimalEntity,
	XML_UndeclaredEntity,
	XML_ErrorParsingEntityName,

	XML_ExpectExternalOrClose,
	XML_ExpectSubOrClose,
	XML_ExpectExternalOrPublicId,
	XML_ExpectExternalIdOrEntityValue,
	XML_InvalidConditionalSection,
	XML_ExpectDtdMarkup,
	XML_IncompleteDtdContent,
	XML_UnclosedConditionalSection,
	XML_UnexpectedCDataEnd,
	XML_ColonInLocalName,
	XML_InvalidContentModel,
	XML_ExpectPcData,
	XML_ExpectNoWhitespace,
	XML_ExpectOp,
	XML_InternalError,
	XML_InvalidAttributeType,
	XML_ExpectAttType,
	XML_Sch_ParEntityRefNesting,
	XML_EnumerationRequired,
	XML_ExpectIgnoreOrInclude,
	XML_InvalidParEntityRef,
	XML_RecursiveGenEntity,
	XML_UnparsedEntityRef,
	XML_ExternalEntityInAttValue,
	XML_ExternalEntityInStandAloneDocument,
	XML_IncompleteEntity,
	XML_UnknownNs,
	XML_XmlnsPrefix,
	XML_NamespaceDeclXmlXmlns,
	XML_BadNamespaceDecl,
	XML_InvalidXmlSpace,
	XML_EntityRefNesting,
	XML_TagMismatch,

};

//////////////////////////////////////////////////////////////////////////////

class BFX_API XMLErrorContext
{
public:
	XMLErrorContext();
	XMLErrorContext(const XMLErrorContext& status);
	virtual ~XMLErrorContext();

	void SetLastError(XMLError nErrorCode, const String& strErrorMsg, int nLineNo, int LinePos);
	XMLErrorContext& operator=(const XMLErrorContext& status);

	bool IsErrorOccurred() const;
	XMLError GetErrorCode() const;
	String GetErrorMsg() const;
	int GetLineNo() const;
	int GetLinePos() const;

private:
	XMLError	m_nErrorCode;
	String		m_strErrorMsg;
	int			m_nLineNo;
	int			m_nLinePos;
};

inline XMLErrorContext::XMLErrorContext()
	: m_nErrorCode(XML_Success), m_nLineNo(-1), m_nLinePos(-1)
{
}
inline XMLErrorContext::XMLErrorContext(const XMLErrorContext& status)
	: m_nErrorCode(status.m_nErrorCode), m_nLineNo(status.m_nLineNo), m_nLinePos(status.m_nLinePos)
{
}
inline XMLErrorContext::~XMLErrorContext()
{
}
inline void XMLErrorContext::SetLastError(XMLError nErrorCode, const String& strErrorMsg, int nLineNo, int nLinePos)
{
	m_nErrorCode = nErrorCode;
	m_strErrorMsg = strErrorMsg;
	m_nLineNo = nLineNo;
	m_nLinePos = nLinePos;
}
inline XMLErrorContext& XMLErrorContext::operator=(const XMLErrorContext& status)
{
	SetLastError(status.m_nErrorCode, status.m_strErrorMsg, status.m_nLineNo, status.m_nLinePos);
	return (*this);
}
inline bool XMLErrorContext::IsErrorOccurred() const
{
	return (m_nErrorCode != XML_Success);
}
inline XMLError XMLErrorContext::GetErrorCode() const
{
	return m_nErrorCode;
}
inline String XMLErrorContext::GetErrorMsg() const
{
	return m_strErrorMsg;
}
inline int XMLErrorContext::GetLineNo() const
{
	return m_nLineNo;
}
inline int XMLErrorContext::GetLinePos() const
{
	return m_nLinePos;
}

}	//	namespace BFX

#endif	//	__BFX_XMLERROR_H__
